-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Begin deprecation cycle of the discrete pulse library #10222
Conversation
One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 5444281151
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick review for the first round. Overall this looks good to me. Do you have plans for continuous
and sampler
module deprecation? They are no longer useful after discrete
is removed (Qiskit Dynamics user may use continuous
to evaluate pulse value for upsampling).
since="0.25.0", | ||
additional_msg="The discrete pulses library, including zero() is pending deprecation." | ||
" Instead, use the SymbolicPulse library to create the waveform with" | ||
" pulse.Constant(amp=0,...).get_waveform().", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also define Zero
function in the symbolic pulse module that wraps Constant
with amp=0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion here. I don't know how much people actually use zero amplitude constants as spacers (@wshanks correctly pointed out elsewhere that there are use cases where you would want something like this) but I suspect it doesn't warrant the extra clutter in the code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a problem of backward compatibility of import. Once we remove this module, people cannot find zero
in the pulse namespace and there is no alternative approach in terms of import. Likely this pulse is not significantly important and can go in this way.
qiskit/pulse/library/discrete.py
Outdated
" pulse.Square(...).get_waveform()." | ||
" Note that pulse.Square() does not support complex values for `amp`." | ||
" Instead, use two float values for (`amp`, `angle`)." | ||
" Also note that the underlying `sign` function used to" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot understand this message without reading code. Maybe we can say new symbolic implementation may return different value at t=0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the problem is not with t=0
because the first time slot is evaluated at t=0.5
. The problem arises only when the sin function is evaluated to exactly zero. This might not even happen (as the tests I added demonstrate). This is somewhat of an edge case. I am not sure how to handle it correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you can write more details (possibly with example code) in release note and say "read release note for more details" here? I don't really like lengthy warning as it might be raised many times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted for matching the functional form of square()
and Square()
, so this discussion was almost mute. However, when I did that I noticed that the phase in square()
was defined somewhat strangely, so I changed that, and now the warning addresses that - but it points the user to the documentation like you suggested.
releasenotes/notes/discrete-pulse-library-deprecation-3a95eba7e29d8d49.yaml
Outdated
Show resolved
Hide resolved
Thanks for quick review @nkanazawa1989 ! |
Thanks I just adde some suggestions in reply. We can probably deprecate continuous and sampler after we drop the discrete module? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks good to me.
Summary
The discrete pulse library serves little purpose today, as the
SymbolicPulse
class and library offer the same functionality at reduced computational cost. This PR completes theSymbolicPulse
counterparts to the discrete library, and begins the deprecation cycle for it.Details and comments
The discrete pulse library serves little purpose today, as the
SymbolicPulse
class and library offer the same functionality at reduced computational cost. Furthermore, it is desired to change the naming convention of the pulses in the symbolic pulse library from camel case to snake case, to reflect the fact that they are no longer subclasses ofSymbolicPulse
. This change is not possible because of naming conflicts with the discrete pulses. For these reasons, it was decided to deprecate the discrete library.This PR:
SymbolicPulse
s to the library, to recreate the functionality of all discrete pulses (namely,Sech
,SechDeriv
,GaussianDeriv
,Square
). Because of the aforementioned naming conflict, the functions use camel case notation.PendingDeprecationWarning
for all pulses in the discrete library, with detailed info about theSymbolicPulse
counterpart.With a few minor exceptions, the
SymbolicPulse
library recreates the same behavior as the discrete library. The one notable difference is the adoption of the (amp
,angle
) representation in the symbolic library.Debatable decisions
SymbolicPulse
form. WhileWaveform
s can be added, the same is not true forSymbolicPulse
s - and this probably removes the prominent use case forGaussianDeriv
andSechDeriv
. (One can consider a DRAG version with Sech instead of Gaussian, butSechDeriv
on its own makes little sense to me.)limit_amplitude
andlimit_amplitude_per_instance
).